package JDBC;

import java.sql.*;

public class JDBCTest {
    public static void main(String[] args) {
        String conn = "jdbc:mysql://localhost:3306/mvc";
        Connection connection = null;
        PreparedStatement pst = null;
        Statement smt = null;
        ResultSet rs = null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(conn,"root","root");
            String sql = "select * from good";
            smt = connection.createStatement();
            rs = smt.executeQuery(sql);
            while(rs.next()){
                System.out.println(rs.getInt("good_id") + "\t" + rs.getString("name"));
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
